- For version control
- track changes in code
- revert to old versions when you commit a terrible error
- To avoid this:
October 25, 2017
To share data and code across teams
To track and merge changes in code from multiple collaborators on a project
Use your work email address (you can add a personal one later if you like) and register for a public (free) account
Send your Github username to Noam ross@ecohealthalliance.org or Toph allen@ecohealthalliance.org so they can add you to the EHA organizational Github
EHA-hosted files can be PRIVATE to the organization. Any data or code that you host on your personal Github.com site will be public.
tree: a directory or folder of files. trees can have multiple branches.branch: a version of the tree. You can make a new branch if you want to test out changes in a file, but don’t want to alter the original.master or master branch: the trunk of the tree.
repo or repository: a file directory hosted on Github. This should include everything you need for a project - raw data, code/scripts, intermediate files, etc.remote: an external place that holds your tree. For us, the remote will be a path to a Github repo, e.g. https://github.com/brooke-watson/intro-to-gitorigin: The default upstream branch.fork: copy someone else's remote to your remoteclone: copy a remote onto your computerfetch: update your clone from a remote that already existspull: fetch updates + check them out into your working directory
merge
add or stage: get your changes ready to be savedcommit: save a record to your repository. A commit is basically a super-save.push: copy that record from your repository (your local computer) to your remote (Github)
committed savesgit diffs).cmnd + space, type "terminal", hit Enter
Brookes-MacBook-Air:Dropbox (EHA) Watson$pwd at the command line prints your working directorycd <path> changes your working directory to <path>clone the git repository, git will download all the files in that repo into your current working directory - basically copying that folder into your home computercloning.cd into the directory where you want this to live.git clone <paste your link here>.cd intro-to-git to get inside the foldergit status
"On Branch Master" "Your branch is up-to-date with 'origin/master’"git checkout -b <branch_name>git checkout -b myname-branchgit statusmkdir oh-boy-a-new-foldertouch wow-what-a-new-text-file.txtintro-to-git/figs.git status again to see your changes.You should see something like this:
git add <filename>
git add 'figs/dwight-howard-cookie-challenge.gif')git add . to add ALL untracked files - use with caution!!git add *.Rmd to add all the .Rmd files, for examplegit diff —-cached to see your changesgit commit -m "Wow, we did it, what a commit”-m: just doing git commit will open a dreadful text editor that you’ll never escape.
git remote -v (if you started by cloning a repo from GitHub, your origin should already be set)git push <remote-name> <your-branch>
git push origin myname-branch
… when creating a new repository.
clone, pull, checkout, status, add, commit, push).git pull before committing and pushing.